package com.atguigu.common.demo;

import com.google.common.base.Stopwatch;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;
import java.util.stream.LongStream;

/**
 * @author gaopeng
 * @date 2021/10/22
 **/
@Slf4j
public class Demo {
    public static void main(String[] args) {
        long[] numbers = LongStream.rangeClosed(1, 10000000).toArray();
        Stopwatch stopwatch = Stopwatch.createStarted();
        long total=0;
        for (long number : numbers) {
            total+=number;
        }

        log.info("for loop takes:{}",stopwatch.elapsed(TimeUnit.MILLISECONDS));
        stopwatch.stop();

    }
}
